{include file="public/nheader" /}
<div class="layui-fluid">
    <div class="layui-card">
        <!-- // 创建数据实例 -->
        <table id="lay-tableList" lay-filter="lay-tableList"></table>
    </div>
</div>
{include file="public/nfooter"}
<script>
    layui.use(['admin', 'layer', 'table', 'form'], function () {
        var admin = layui.admin;
        var layer = layui.layer;
        var table = layui.table;        // 表格
        var form = layui.form;
        form.on("submit(formSearch)", function (post) {
            // 获取用户id
            if (post.field.province || post.field.city || post.field.area || post.field.street) {
                if (!post.field.type) {
                    layer.error('请填写合伙人类型');
                    return false;
                }
            }
            layui.$.get("{:url('')}", post.field, function (res) {
                if (res.code == 200) {
                    table.reload("lay-tableList", {
                        page: {
                            curr: 1
                        },
                        where: post.field
                    })
                }
                else {
                    layer.error(res.msg);
                }
            }, 'json');

            return false;
        })
        /*
         * 初始化表格
        */
        var isTable = table.render({
            elem: "#lay-tableList",
            where: {
                agentid: "{:input('agentid/d',0)}"
            }
            , url: "{:url()}"
            , page: true
            , size: 'lg'
            , even: true
            , cols: [[
                { type: 'checkbox', width: 60 },
                { field: 'id', align: 'center', sort: true, width: 80, title: 'ID' },
                {
                    field: 'type', align: 'center', width: 120, templet: function (d) {
                        var text = '';
                        if (d.type == 1) {
                            text = '<span class="layui-badge layui-bg-blue">全国代理</span>';
                        }
                        if (d.type == 2) {
                            text = '<span class="layui-badge layui-bg-orange">城市代理</span>';
                        }
                        if (d.type == 3) {
                            text = '<span class="layui-badge layui-bg-green">区域代理</span>';
                        }
                        if (d.type == 4) {
                            text = '<span class="layui-badge layui-bg-cyan">街道代理</span>';
                        }
                        return text;

                    }, title: '类型'
                },
                { field: 'province_list', width: 150, align: 'center', title: '省份' },
                { field: 'city_list', width: 150, align: 'center', title: '城市' },
                { field: 'area_list', width: 150, align: 'center', title: '区县' },
                { field: 'street_list', width: 150, align: 'center', title: '街道' },
                { field: 'created', width: 200, align: 'center', title: '添加时间' },
            ]]
        })
    })
</script>
</body>